import { requestHttp } from '../httpRequest';
/**
 *
 * @param {string} url 接口具体地址
 * @param {*} data  发给后端接口的数据
 * @param {'GET' | 'POST' | 'PUT' | 'DELETE'} method 请求方式 => 'GET' || 'POST' || 'PUT' || 'DELETE',
 * @param {*} option 其它配置项
 * @returns {Promise<any | boolean>}
 */
const request = async (
  url = '',
  data = {},
  method = 'GET',
  option = { ops: {}, proxyType: 'common' }
) => {
  data.api = url;
  data.method = method;
  try {
    let res = await requestHttp(data, option.ops, option.proxyType);
    return res;
  } catch (err) {
    console.error(err);
    return false;
  }
};

export default request;
